home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / netz / term / extras / source / term-source.lha / termBoxes.c < prev    next >
C/C++ Source or Header  |  1995-04-14  |  13KB  |  766 lines

  1. /*
  2. **    termBoxes.c
  3. **
  4. **    Text box management support routines
  5. **
  6. **    Copyright © 1990-1995 by Olaf `Olsen' Barthel
  7. **        All Rights Reserved
  8. */
  9.  
  10. #include "termGlobal.h"
  11.  
  12.     /* Sizing data. */
  13.  
  14. STATIC struct RastPort    *SZ_RPort;
  15. STATIC struct TextFont    *SZ_TextFont;
  16. STATIC struct Screen    *SZ_Screen;
  17.  
  18. STATIC LONG         SZ_Left,
  19.              SZ_Top,
  20.              SZ_CurrentLeft,
  21.              SZ_CurrentTop,
  22.              SZ_CurrentWidth,
  23.              SZ_MaxWidth,
  24.              SZ_TextPen,
  25.              SZ_BackPen,
  26.              SZ_LastLeft,
  27.              SZ_LastTop,
  28.              SZ_LastWidth,
  29.              SZ_LastHeight,
  30.              SZ_AverageGlyphWidth;
  31.  
  32.     /* SZ_GetLeftEdge():
  33.      *
  34.      *    Get the current object left edge.
  35.      */
  36.  
  37. LONG
  38. SZ_GetLeftEdge()
  39. {
  40.     return(SZ_CurrentLeft);
  41. }
  42.  
  43.     /* SZ_SetTopEdge(LONG Top):
  44.      *
  45.      *    Set the current object top edge.
  46.      */
  47.  
  48. VOID __regargs
  49. SZ_SetTopEdge(LONG Top)
  50. {
  51.     SZ_CurrentTop = Top;
  52. }
  53.  
  54.     /* SZ_SetLeftEdge(LONG Left):
  55.      *
  56.      *    Set the current object left edge.
  57.      */
  58.  
  59. VOID __regargs
  60. SZ_SetLeftEdge(LONG Left)
  61. {
  62.     SZ_CurrentLeft = Left;
  63. }
  64.  
  65.     /* SZ_SetAbsoluteTop(LONG Top):
  66.      *
  67.      *    Set new inner window top edge.
  68.      */
  69.  
  70. VOID __regargs
  71. SZ_SetAbsoluteTop(LONG Top)
  72. {
  73.     SZ_Top = Top;
  74. }
  75.  
  76.     /* SZ_SetAbsoluteLeft(LONG Left):
  77.      *
  78.      *    Set new inner window left edge.
  79.      */
  80.  
  81. VOID __regargs
  82. SZ_SetAbsoluteLeft(LONG Left)
  83. {
  84.     SZ_Left = Left;
  85. }
  86.  
  87.     /* SZ_SetWidth(LONG Width):
  88.      *
  89.      *    Set current object width.
  90.      */
  91.  
  92. VOID __regargs
  93. SZ_SetWidth(LONG Width)
  94. {
  95.     SZ_CurrentWidth = Width;
  96. }
  97.  
  98.     /* SZ_AddLeftOffset(LONG Offset):
  99.      *
  100.      *    Update current object left offset.
  101.      */
  102.  
  103. VOID __regargs
  104. SZ_AddLeftOffset(LONG Offset)
  105. {
  106.     SZ_CurrentLeft += Offset;
  107. }
  108.  
  109.     /* SZ_LeftOffsetN(LONG DataArray,...):
  110.      *
  111.      *    Determine the maximum length of a number of
  112.      *    gadget labels (first, second, third item, -1 terminates
  113.      *    the array).
  114.      */
  115.  
  116. LONG __stdargs
  117. SZ_LeftOffsetN(LONG DataArray,...)
  118. {
  119.     LONG    *Data = &DataArray,
  120.          Len,
  121.          Max = 0;
  122.     STRPTR     String;
  123.  
  124.     while(*Data != -1)
  125.     {
  126.         String = LocaleString(*Data++);
  127.  
  128.         if((Len = TextLength(SZ_RPort,String,strlen(String))) > Max)
  129.             Max = Len;
  130.     }
  131.  
  132.     return(Max + INTERWIDTH);
  133. }
  134.  
  135.     /* SZ_SizeCleanup():
  136.      *
  137.      *    Free data allocated by SZ_SizeSetup().
  138.      */
  139.  
  140. VOID
  141. SZ_SizeCleanup()
  142. {
  143.     if(SZ_TextFont)
  144.     {
  145.         CloseFont(SZ_TextFont);
  146.  
  147.         SZ_TextFont = NULL;
  148.     }
  149.  
  150.     if(SZ_RPort)
  151.     {
  152.         FreeVecPooled(SZ_RPort);
  153.  
  154.         SZ_RPort = NULL;
  155.     }
  156. }
  157.  
  158.     /* SZ_SizeSetup(struct Screen *Screen,struct TextAttr *TextAttr):
  159.      *
  160.      *    Perform setups for gadget creation.
  161.      */
  162.  
  163. BYTE __regargs
  164. SZ_SizeSetup(struct Screen *Screen,struct TextAttr *TextAttr)
  165. {
  166.     SZ_SizeCleanup();
  167.  
  168.     if(Screen)
  169.     {
  170.         struct DrawInfo *DrawInfo;
  171.  
  172.         if(DrawInfo = GetScreenDrawInfo(Screen))
  173.         {
  174.             SZ_TextPen = DrawInfo -> dri_Pens[TEXTPEN];
  175.             SZ_BackPen = DrawInfo -> dri_Pens[BACKGROUNDPEN];
  176.  
  177.             FreeScreenDrawInfo(Screen,DrawInfo);
  178.         }
  179.     }
  180.     else
  181.     {
  182.         if(!TextAttr)
  183.             return(FALSE);
  184.     }
  185.  
  186.     SZ_Screen = Screen;
  187.  
  188.     if(SZ_RPort = (struct RastPort *)AllocVecPooled(sizeof(struct RastPort),MEMF_ANY | MEMF_CLEAR))
  189.     {
  190.         InitRastPort(SZ_RPort);
  191.  
  192.         if(!TextAttr)
  193.             TextAttr = Screen -> Font;
  194.  
  195.         if(SZ_TextFont = (struct TextFont *)OpenDiskFont(TextAttr))
  196.         {
  197.             UWORD    i,Width;
  198.             UBYTE    Char;
  199.  
  200.             InterWidth = INTERWIDTH;
  201.  
  202.             if(SZ_TextFont -> tf_YSize <= 8)
  203.                 InterHeight = 1;
  204.             else
  205.                 InterHeight = SZ_TextFont -> tf_YSize / 4;
  206.  
  207.             SetFont(SZ_RPort,SZ_TextFont);
  208.  
  209.             SZ_AverageGlyphWidth = 0;
  210.  
  211.             for(i = 0 ; i < 256 ; i++)
  212.             {
  213.                 Char = i;
  214.  
  215.                 Width = TextLength(SZ_RPort,&Char,1);
  216.  
  217.                 SZ_AverageGlyphWidth += Width;
  218.             }
  219.  
  220.             SZ_AverageGlyphWidth /= 256;
  221.  
  222.             SZ_Left = InterWidth;
  223.  
  224.             if(Screen)
  225.                 SZ_Top = Screen -> WBorTop + Screen -> Font -> ta_YSize + 1 + InterHeight;
  226.             else
  227.                 SZ_Top = 0;
  228.  
  229.             SZ_CurrentLeft    = InterWidth;
  230.             SZ_CurrentTop    = SZ_Top;
  231.  
  232.             SZ_CurrentWidth    = 0;
  233.             SZ_MaxWidth    = 0;
  234.  
  235.             return(TRUE);
  236.         }
  237.     }
  238.  
  239.     SZ_SizeCleanup();
  240.  
  241.     return(FALSE);
  242. }
  243.  
  244.     /* SZ_GetLen(STRPTR String):
  245.      *
  246.      *    Get the string pixel width, measured using the average
  247.      *    glyph width.
  248.      */
  249.  
  250. ULONG __regargs
  251. SZ_GetLen(STRPTR String)
  252. {
  253.     return(strlen(String) * SZ_AverageGlyphWidth);
  254. }
  255.  
  256.     /* SZ_FreeBox(struct TextBox *Box):
  257.      *
  258.      *    Free a text box.
  259.      */
  260.  
  261. STATIC VOID __regargs
  262. SZ_FreeBox(struct TextBox *Box)
  263. {
  264.     if(Box)
  265.     {
  266.         if(Box -> Text)
  267.         {
  268.             LONG i;
  269.  
  270.             for(i = 0 ; i < Box -> NumLines ; i++)
  271.             {
  272.                 if(Box -> Text[i])
  273.                     FreeVecPooled(Box -> Text[i]);
  274.             }
  275.  
  276.             FreeVecPooled(Box -> Text);
  277.         }
  278.  
  279.         if(Box -> Title)
  280.             FreeVecPooled(Box -> Title);
  281.  
  282.         FreeVecPooled(Box);
  283.     }
  284. }
  285.  
  286.     /* SZ_FreeBoxes(struct TextBox *FirstBox):
  287.      *
  288.      *    Free a number of text boxes.
  289.      */
  290.  
  291. VOID __regargs
  292. SZ_FreeBoxes(struct TextBox *FirstBox)
  293. {
  294.     if(FirstBox)
  295.     {
  296.         struct TextBox *NextBox;
  297.  
  298.         do
  299.         {
  300.             NextBox = FirstBox -> NextBox;
  301.  
  302.             SZ_FreeBox(FirstBox);
  303.  
  304.             FirstBox = NextBox;
  305.         }
  306.         while(FirstBox);
  307.     }
  308. }
  309.  
  310.     /* SZ_BoxWidth(LONG Chars):
  311.      *
  312.      *    Determine the width of a text box.
  313.      */
  314.  
  315. LONG __regargs
  316. SZ_BoxWidth(LONG Chars)
  317. {
  318.     return((LONG)(4 + SZ_AverageGlyphWidth * Chars + 4));
  319. }
  320.  
  321.     /* SZ_BoxHeight(LONG Lines):
  322.      *
  323.      *    Determine the height of a text box.
  324.      */
  325.  
  326. LONG __regargs
  327. SZ_BoxHeight(LONG Lines)
  328. {
  329.     return(2 + SZ_TextFont -> tf_YSize * Lines + 2);
  330. }
  331.  
  332.     /* SZ_SetTitlePen(struct TextBox *Box,LONG FgPen,LONG BgPen):
  333.      *
  334.      *    Set the text box list title text rendering pens.
  335.      */
  336.  
  337. VOID __regargs
  338. SZ_SetTitlePen(struct TextBox *Box,LONG FgPen,LONG BgPen)
  339. {
  340.     while(Box)
  341.     {
  342.         Box -> TitleFgPen = FgPen;
  343.         Box -> TitleBgPen = BgPen;
  344.  
  345.         Box = Box -> NextBox;
  346.     }
  347. }
  348.  
  349.     /* SZ_CreateTextBox(struct TextBox **FirstBox,...):
  350.      *
  351.      *    Create a text box, this routine works similar
  352.      *    to the CreateGadget() frontend.
  353.      */
  354.  
  355. struct TextBox * __stdargs
  356. SZ_CreateTextBox(struct TextBox **FirstBox,...)
  357. {
  358.     va_list                 VarArgs;
  359.     struct TagItem            *TagList,
  360.                     *ThisTag;
  361.     LONG                 Chars,Lines,
  362.                      Width,
  363.                      Height,
  364.                      Left = SZ_CurrentLeft;
  365.     BYTE                 AutoWidth    = FALSE,
  366.                      MoveDown    = TRUE,
  367.                      SetLeft    = FALSE,
  368.                      SetBelow    = FALSE;
  369.  
  370.     struct TextBox            *Box;
  371.     LONG                 i;
  372.  
  373.     va_start(VarArgs,FirstBox);
  374.  
  375.     TagList = (struct TagItem *)VarArgs;
  376.  
  377.     if(ThisTag = FindTagItem(SZ_Lines,TagList))
  378.         Lines = (LONG)ThisTag -> ti_Data;
  379.     else
  380.         return(NULL);
  381.  
  382.     Height = 2 + SZ_TextFont -> tf_YSize * Lines + 2;
  383.  
  384.     if(ThisTag = FindTagItem(SZ_AutoWidth,TagList))
  385.         AutoWidth = ThisTag -> ti_Data;
  386.  
  387.     if(!AutoWidth)
  388.         return(NULL);
  389.     else
  390.         Chars = (SZ_CurrentWidth - 8) / SZ_AverageGlyphWidth;
  391.  
  392.     if(!(Box = (struct TextBox *)AllocVecPooled(sizeof(struct TextBox),MEMF_ANY | MEMF_CLEAR)))
  393.         return(NULL);
  394.  
  395.     if(ThisTag = FindTagItem(SZ_NewColumn,TagList))
  396.     {
  397.         if(ThisTag -> ti_Data)
  398.         {
  399.             SZ_CurrentTop    = SZ_Top;
  400.             Left        = Left + SZ_MaxWidth + InterWidth;
  401.  
  402.             SZ_MaxWidth    = 0;
  403.         }
  404.     }
  405.  
  406.     if(ThisTag = FindTagItem(SZ_AutoWidth,TagList))
  407.         AutoWidth = ThisTag -> ti_Data;
  408.  
  409.     if(!AutoWidth)
  410.         Width = SZ_BoxWidth(Chars);
  411.     else
  412.         Width = SZ_CurrentWidth;
  413.  
  414.     Box -> Left        = Left;
  415.     Box -> Top        = SZ_CurrentTop;
  416.     Box -> Width        = Width;
  417.     Box -> Height        = Height;
  418.  
  419.     Box -> LineWidth    = Chars * SZ_AverageGlyphWidth;
  420.     Box -> LineHeight    = SZ_TextFont -> tf_YSize;
  421.  
  422.     Box -> NumChars        = Chars;
  423.     Box -> NumLines        = Lines;
  424.  
  425.     Box -> TitleFgPen    = SZ_TextPen;
  426.     Box -> TitleBgPen    = SZ_BackPen;
  427.     Box -> TextPen        = SZ_TextPen;
  428.  
  429.     if(!(Box -> Title = (STRPTR *)AllocVecPooled(sizeof(STRPTR) * Lines,MEMF_ANY | MEMF_CLEAR)))
  430.     {
  431.         SZ_FreeBox(Box);
  432.  
  433.         return(NULL);
  434.     }
  435.  
  436.     if(!(Box -> Text = (STRPTR *)AllocVecPooled(sizeof(STRPTR) * Lines,MEMF_ANY | MEMF_CLEAR)))
  437.     {
  438.         SZ_FreeBox(Box);
  439.  
  440.         return(NULL);
  441.     }
  442.  
  443.     for(i = 0 ; i < Lines ; i++)
  444.     {
  445.         if(!(Box -> Text[i] = (STRPTR)AllocVecPooled(Chars + 1,MEMF_ANY | MEMF_CLEAR)))
  446.         {
  447.             SZ_FreeBox(Box);
  448.  
  449.             return(NULL);
  450.         }
  451.     }
  452.  
  453.     if(SetBelow)
  454.         MoveDown = FALSE;
  455.  
  456.     if(MoveDown)
  457.         SZ_CurrentTop = SZ_CurrentTop + Height + InterHeight;
  458.     else
  459.         SZ_MaxWidth = 0;
  460.  
  461.     if(Width > SZ_MaxWidth)
  462.         SZ_MaxWidth = Width;
  463.  
  464.     if(!SetLeft)
  465.         SZ_CurrentLeft = Left;
  466.  
  467.     if(!(*FirstBox))
  468.         *FirstBox = Box;
  469.     else
  470.     {
  471.         struct TextBox *CurrentBox = *FirstBox;
  472.  
  473.         while(CurrentBox -> NextBox)
  474.             CurrentBox = CurrentBox -> NextBox;
  475.  
  476.         CurrentBox -> NextBox = Box;
  477.     }
  478.  
  479.     return(Box);
  480. }
  481.  
  482.     /* SZ_SetBoxTitles(struct TextBox *Box,STRPTR Array,...):
  483.      *
  484.      *    Set the titles displayed in a text box.
  485.      */
  486.  
  487. VOID __stdargs
  488. SZ_SetBoxTitles(struct TextBox *Box,STRPTR Array,...)
  489. {
  490.     if(Box)
  491.     {
  492.         STRPTR    *Data = &Array;
  493.         LONG     i = 0;
  494.  
  495.         while(*Data != NULL)
  496.         {
  497.             if(i < Box -> NumLines)
  498.                 Box -> Title[i++] = *Data;
  499.  
  500.             Data++;
  501.         }
  502.     }
  503. }
  504.  
  505.     /* SZ_SetLine():
  506.      *
  507.      *    Print a string into a text box, plain version.
  508.      */
  509.  
  510. VOID __regargs
  511. SZ_SetLine(struct RastPort *RPort,struct TextBox *Box,LONG Line,STRPTR String)
  512. {
  513.     BYTE         FgPen    = ReadAPen(RPort),
  514.              BgPen    = ReadBPen(RPort),
  515.              DrMd    = ReadDrMd(RPort);
  516.     struct TextFont    *Font    = RPort -> Font;
  517.  
  518.     LONG         Width,Len,
  519.              Left    = Box -> Left + 4,
  520.              Top    = Box -> Top + 2 + Line * Box -> LineHeight;
  521.  
  522.     if(DrMd != JAM2)
  523.         SetDrMd(RPort,JAM2);
  524.  
  525.     if(FgPen != Box -> TextPen)
  526.         SetAPen(RPort,Box -> TextPen);
  527.  
  528.     if(BgPen != SZ_BackPen)
  529.         SetBPen(RPort,SZ_BackPen);
  530.  
  531.     if(Font != UserTextFont)
  532.         SetFont(RPort,UserTextFont);
  533.  
  534.     if(Len = strlen(String))
  535.     {
  536.         if(Len > Box -> NumChars)
  537.             Len = Box -> NumChars;
  538.  
  539.         while(Len > 0 && TextLength(RPort,String,Len) > Box -> LineWidth)
  540.             Len--;
  541.  
  542.         if(Len)
  543.         {
  544.             Width = TextLength(RPort,String,Len);
  545.  
  546.             Move(RPort,Left,Top + RPort -> Font -> tf_Baseline);
  547.             Text(RPort,String,Len);
  548.         }
  549.         else
  550.             Width = 0;
  551.     }
  552.     else
  553.         Width = 0;
  554.  
  555.     if(Width != Box -> LineWidth)
  556.     {
  557.         if(FgPen != SZ_BackPen)
  558.         {
  559.             SetAPen(RPort,SZ_BackPen);
  560.  
  561.             RectFill(RPort,Left + Width,Top,Left + Box -> LineWidth - 1,Top + Box -> LineHeight - 1);
  562.  
  563.             SetAPen(RPort,FgPen);
  564.         }
  565.         else
  566.             RectFill(RPort,Left + Width,Top,Left + Box -> LineWidth - 1,Top + Box -> LineHeight - 1);
  567.     }
  568.  
  569.     if(DrMd != JAM2)
  570.         SetDrMd(RPort,DrMd);
  571.  
  572.     if(String != Box -> Text[Line])
  573.     {
  574.         if(Len > 0)
  575.             CopyMem(String,Box -> Text[Line],Len);
  576.  
  577.         Box -> Text[Line][Len] = 0;
  578.     }
  579.  
  580.     if(Font != UserTextFont)
  581.         SetFont(RPort,Font);
  582.  
  583.     if(BgPen != SZ_BackPen)
  584.         SetBPen(RPort,BgPen);
  585.  
  586.     SetAPen(RPort,FgPen);
  587. }
  588.  
  589.     /* SZ_PrintLine():
  590.      *
  591.      *    Print a string into a text box, varargs version.
  592.      */
  593.  
  594. VOID __stdargs
  595. SZ_PrintLine(struct RastPort *RPort,struct TextBox *Box,LONG Line,STRPTR String,...)
  596. {
  597.     va_list    VarArgs;
  598.     UBYTE    Buffer[256];
  599.  
  600.     va_start(VarArgs,String);
  601.     VSPrintf(Buffer,String,VarArgs);
  602.     va_end(VarArgs);
  603.  
  604.     SZ_SetLine(RPort,Box,Line,Buffer);
  605. }
  606.  
  607.     /* SZ_DrawBox(struct RastPort *RPort,struct TextBox *Box):
  608.      *
  609.      *    (Re-)Draw a text box.
  610.      */
  611.  
  612. STATIC VOID __regargs
  613. SZ_DrawBox(struct RastPort *RPort,struct TextBox *Box)
  614. {
  615.     if(Box)
  616.     {
  617.         LONG         LineY,i,Len,FgPen = ReadAPen(RPort),BgPen = ReadBPen(RPort),DrMd = ReadDrMd(RPort);
  618.         struct TextFont    *Font = RPort -> Font;
  619.  
  620.         if(Font != UserTextFont)
  621.             SetFont(RPort,UserTextFont);
  622.  
  623.         if(FgPen != SZ_BackPen)
  624.         {
  625.             SetAPen(RPort,SZ_BackPen);
  626.  
  627.             RectFill(RPort,Box -> Left,Box -> Top,Box -> Left + Box -> Width - 1,Box -> Top + Box -> Height - 1);
  628.  
  629.             SetAPen(RPort,FgPen);
  630.         }
  631.         else
  632.             RectFill(RPort,Box -> Left,Box -> Top,Box -> Left + Box -> Width - 1,Box -> Top + Box -> Height - 1);
  633.  
  634.         DrawBevelBox(RPort,Box -> Left,Box -> Top,Box -> Width,Box -> Height,
  635.             GT_VisualInfo,    VisualInfo,
  636.             GTBB_Recessed,    TRUE,
  637.         TAG_DONE);
  638.  
  639.         LineY = Box -> Top + 2 + RPort -> Font -> tf_Baseline;
  640.  
  641.         SetAPen(RPort,Box -> TitleFgPen);
  642.         SetBPen(RPort,Box -> TitleBgPen);
  643.         SetDrMd(RPort,JAM2);
  644.  
  645.         for(i = 0 ; i < Box -> NumLines ; i++)
  646.         {
  647.             if(Len = strlen(Box -> Title[i]))
  648.             {
  649.                 Move(RPort,Box -> Left - INTERWIDTH - TextLength(RPort,Box -> Title[i],Len),LineY);
  650.                 Text(RPort,Box -> Title[i],Len);
  651.             }
  652.  
  653.             LineY += Box -> LineHeight;
  654.         }
  655.  
  656.         for(i = 0 ; i < Box -> NumLines ; i++)
  657.             SZ_PrintLine(RPort,Box,i,Box -> Text[i]);
  658.  
  659.         SetAPen(RPort,FgPen);
  660.         SetBPen(RPort,BgPen);
  661.  
  662.         SetDrMd(RPort,DrMd);
  663.  
  664.         if(Font != UserTextFont)
  665.             SetFont(RPort,Font);
  666.     }
  667. }
  668.  
  669.     /* SZ_DrawBoxes(struct RastPort *RPort,struct TextBox *FirstBox):
  670.      *
  671.      *    (Re-)Draw a number of text boxes.
  672.      */
  673.  
  674. VOID __regargs
  675. SZ_DrawBoxes(struct RastPort *RPort,struct TextBox *FirstBox)
  676. {
  677.     do
  678.         SZ_DrawBox(RPort,FirstBox);
  679.     while(FirstBox = FirstBox -> NextBox);
  680. }
  681.  
  682.     /* SZ_MoveBox(struct TextBox *Box,LONG Left,LONG Top):
  683.      *
  684.      *    Change the location of a text box.
  685.      */
  686.  
  687. STATIC VOID __regargs
  688. SZ_MoveBox(struct TextBox *Box,LONG Left,LONG Top)
  689. {
  690.     Box -> Left    += Left;
  691.     Box -> Top    += Top;
  692. }
  693.  
  694.     /* SZ_MoveBoxes(struct TextBox *FirstBox,LONG Left,LONG Top):
  695.      *
  696.      *    Change the locations of a number of text boxes.
  697.      */
  698.  
  699. VOID __regargs
  700. SZ_MoveBoxes(struct TextBox *FirstBox,LONG Left,LONG Top)
  701. {
  702.     do
  703.         SZ_MoveBox(FirstBox,Left,Top);
  704.     while(FirstBox = FirstBox -> NextBox);
  705. }
  706.  
  707.     /* SZ_SetBox(struct TextBox *Box,LONG Left,LONG Top):
  708.      *
  709.      *    Set the location of a text box.
  710.      */
  711.  
  712. STATIC VOID __regargs
  713. SZ_SetBox(struct TextBox *Box,LONG Left,LONG Top)
  714. {
  715.     if(Left >= 0)
  716.         Box -> Left = Left;
  717.  
  718.     if(Top >= 0)
  719.         Box -> Top = Top;
  720. }
  721.  
  722.     /* SZ_SetBoxes(struct TextBox *FirstBox,LONG Left,LONG Top):
  723.      *
  724.      *    Set the locations of a number of text boxes.
  725.      */
  726.  
  727. VOID __regargs
  728. SZ_SetBoxes(struct TextBox *FirstBox,LONG Left,LONG Top)
  729. {
  730.     do
  731.         SZ_SetBox(FirstBox,Left,Top);
  732.     while(FirstBox = FirstBox -> NextBox);
  733. }
  734.  
  735.     /* SZ_GetBoxInfo(struct TextBox *Box,LONG Type):
  736.      *
  737.      *    Query information on a certain text box.
  738.      */
  739.  
  740. LONG __regargs
  741. SZ_GetBoxInfo(struct TextBox *Box,LONG Type)
  742. {
  743.     switch(Type)
  744.     {
  745.         case BOX_LEFT:
  746.  
  747.             return(Box -> Left);
  748.  
  749.         case BOX_TOP:
  750.  
  751.             return(Box -> Top);
  752.  
  753.         case BOX_WIDTH:
  754.  
  755.             return(Box -> Width);
  756.  
  757.         case BOX_HEIGHT:
  758.  
  759.             return(Box -> Height);
  760.  
  761.         default:
  762.  
  763.             return(0);
  764.     }
  765. }
  766.